package org.mx.dal.entity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.Getter;
import lombok.Setter;

/**
 * Geo Shape Point定义类
 * 
 * @author john.peng
 *
 */
@Getter
@Setter
public class GeoShapePoint extends GeoShape {
	private static final Logger logger = LoggerFactory.getLogger(GeoShapePoint.class);

	@JsonIgnore
	private GeoPoint point = null;

	/**
	 * 默认的构造函数
	 */
	public GeoShapePoint() {
		super();
		super.setType("Point");
	}

	private void fillData() {
		if (point == null) {
			if (logger.isWarnEnabled()) {
				logger.warn("The point is null.");
			}
			super.setCoordinates(new double[0]);
		} else {
			double[] coordinates = new double[2];
			coordinates[0] = point.getLon();
			coordinates[1] = point.getLat();
			super.setCoordinates(coordinates);
		}
	}

	/**
	 * 设置点
	 * @param point 点
	 * @return GeoShapePoint
	 */
	public GeoShapePoint setPoint(GeoPoint point) {
		this.point = point;
		fillData();
		return this;
	}
}
